home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / ActiveX Controlls / CD Writer Pro ActiveX Control / CD Writer Pro ActiveX Control.exe / %MAINDIR% / VBSample1 / frmDiscInfo.frm (.txt) next >
Encoding:
Visual Basic Form  |  2003-04-16  |  11.4 KB  |  333 lines

  1. VERSION 5.00
  2. Begin VB.Form frmDiscInfo 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Disc Info..."
  5.    ClientHeight    =   3345
  6.    ClientLeft      =   2760
  7.    ClientTop       =   3750
  8.    ClientWidth     =   4620
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   3345
  13.    ScaleWidth      =   4620
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.Frame fraInfo 
  17.       Caption         =   "Disc Properties"
  18.       Height          =   2280
  19.       Left            =   255
  20.       TabIndex        =   3
  21.       Top             =   120
  22.       Width           =   4170
  23.       Begin VB.Label lblMediaType 
  24.          Caption         =   "Media Type:"
  25.          Height          =   240
  26.          Left            =   330
  27.          TabIndex        =   16
  28.          Top             =   315
  29.          Width           =   1470
  30.       End
  31.       Begin VB.Label lblValueMediaType 
  32.          Caption         =   "N/A"
  33.          Height          =   240
  34.          Left            =   2175
  35.          TabIndex        =   15
  36.          Top             =   315
  37.          Width           =   1815
  38.       End
  39.       Begin VB.Label lblValueDiscStatus 
  40.          Caption         =   "N/A"
  41.          Height          =   240
  42.          Left            =   2175
  43.          TabIndex        =   13
  44.          Top             =   1575
  45.          Width           =   1815
  46.       End
  47.       Begin VB.Label lblDiscStatus 
  48.          Caption         =   "Disc Status:"
  49.          Height          =   240
  50.          Left            =   330
  51.          TabIndex        =   12
  52.          Top             =   1575
  53.          Width           =   1470
  54.       End
  55.       Begin VB.Label lblValueFreeSpaceBlocks 
  56.          Caption         =   "N/A"
  57.          Height          =   240
  58.          Left            =   2190
  59.          TabIndex        =   11
  60.          Top             =   1890
  61.          Width           =   1815
  62.       End
  63.       Begin VB.Label lblFreeSpace 
  64.          Caption         =   "Free Space Blocks:"
  65.          Height          =   240
  66.          Left            =   330
  67.          TabIndex        =   10
  68.          Top             =   1890
  69.          Width           =   1470
  70.       End
  71.       Begin VB.Label lblValueDiscType 
  72.          Caption         =   "N/A"
  73.          Height          =   240
  74.          Left            =   2175
  75.          TabIndex        =   9
  76.          Top             =   1260
  77.          Width           =   1815
  78.       End
  79.       Begin VB.Label lblDiscType 
  80.          Caption         =   "Disc Type (CD Only):"
  81.          Height          =   240
  82.          Left            =   330
  83.          TabIndex        =   8
  84.          Top             =   1260
  85.          Width           =   1515
  86.       End
  87.       Begin VB.Label lblValueLastSessionStatus 
  88.          Caption         =   "N/A"
  89.          Height          =   240
  90.          Left            =   2175
  91.          TabIndex        =   7
  92.          Top             =   945
  93.          Width           =   1815
  94.       End
  95.       Begin VB.Label lblSessionStatus 
  96.          Caption         =   "Last Session Status:"
  97.          Height          =   240
  98.          Left            =   330
  99.          TabIndex        =   6
  100.          Top             =   945
  101.          Width           =   1470
  102.       End
  103.       Begin VB.Label lblValueSessions 
  104.          Caption         =   "N/A"
  105.          Height          =   240
  106.          Left            =   2175
  107.          TabIndex        =   5
  108.          Top             =   630
  109.          Width           =   1815
  110.       End
  111.       Begin VB.Label lblSessions 
  112.          Caption         =   "Number of Sessions:"
  113.          Height          =   240
  114.          Left            =   330
  115.          TabIndex        =   4
  116.          Top             =   630
  117.          Width           =   1470
  118.       End
  119.    End
  120.    Begin VB.CommandButton cmdCloseDisc 
  121.       Caption         =   "Close Disc"
  122.       Height          =   375
  123.       Left            =   1755
  124.       TabIndex        =   2
  125.       Top             =   2820
  126.       Width           =   1395
  127.    End
  128.    Begin VB.CommandButton cmdCloseSession 
  129.       Caption         =   "Close Session"
  130.       Height          =   375
  131.       Left            =   300
  132.       TabIndex        =   1
  133.       Top             =   2820
  134.       Width           =   1395
  135.    End
  136.    Begin VB.CommandButton cmdOK 
  137.       Caption         =   "OK"
  138.       Height          =   375
  139.       Left            =   3660
  140.       TabIndex        =   0
  141.       Top             =   2820
  142.       Width           =   780
  143.    End
  144.    Begin VB.Label lblStatus 
  145.       Alignment       =   2  'Center
  146.       BeginProperty Font 
  147.          Name            =   "MS Sans Serif"
  148.          Size            =   8.25
  149.          Charset         =   0
  150.          Weight          =   700
  151.          Underline       =   0   'False
  152.          Italic          =   0   'False
  153.          Strikethrough   =   0   'False
  154.       EndProperty
  155.       Height          =   300
  156.       Left            =   285
  157.       TabIndex        =   14
  158.       Top             =   2520
  159.       Width           =   4065
  160.    End
  161. Attribute VB_Name = "frmDiscInfo"
  162. Attribute VB_GlobalNameSpace = False
  163. Attribute VB_Creatable = False
  164. Attribute VB_PredeclaredId = True
  165. Attribute VB_Exposed = False
  166. Option Explicit
  167. Private WithEvents mobjCDPro As CDWriterPro
  168. Attribute mobjCDPro.VB_VarHelpID = -1
  169. Private mblnClosing As Boolean
  170. '****************************************************************
  171. '****************************************************************
  172. 'COPYRIGHT 2003 NUMEDIA SOFT, INC.
  173. 'This is a sample of how you could use the CDWriterPro control.
  174. 'There are improvements which could be made rather easily.
  175. 'Feel free to modify it as you see fit.
  176. '****************************************************************
  177. '****************************************************************
  178. Private Sub cmdCloseDisc_Click()
  179.     mblnClosing = True
  180.     cmdOK.Enabled = False
  181.     cmdCloseDisc.Enabled = False
  182.     cmdCloseSession.Enabled = False
  183.     'Call close last session method
  184.     If mobjCDPro.CloseLastSession(True) = False Then
  185.         MsgBox "Error attempting to Close Disc!", vbCritical, App.Title
  186.         mblnClosing = False
  187.         cmdOK.Enabled = True
  188.         cmdCloseDisc.Enabled = True
  189.         cmdCloseSession.Enabled = True
  190.     End If
  191.     'Events will tell us if it succeeded or not
  192. End Sub
  193. Private Sub cmdCloseSession_Click()
  194.     mblnClosing = True
  195.     cmdOK.Enabled = False
  196.     cmdCloseDisc.Enabled = False
  197.     cmdCloseSession.Enabled = False
  198.     'Call close last session method
  199.     If mobjCDPro.CloseLastSession(False) = False Then
  200.         MsgBox "Error attempting to Close Session!", vbCritical, App.Title
  201.         mblnClosing = False
  202.         cmdOK.Enabled = True
  203.         cmdCloseDisc.Enabled = True
  204.         cmdCloseSession.Enabled = True
  205.     End If
  206.     'Events will tell us if it succeeded or not
  207. End Sub
  208. Private Sub cmdOK_Click()
  209.      Unload Me
  210. End Sub
  211. Private Sub Form_Unload(Cancel As Integer)
  212.     If mblnClosing = True Then
  213.         Cancel = 1
  214.         Exit Sub
  215.     End If
  216.     'Set instance to nothing
  217.     Set mobjCDPro = Nothing
  218. End Sub
  219. Public Sub ShowDiscInfo(objCDR As CDWriterPro, frmParent As Form)
  220.     'Set local object
  221.     Set mobjCDPro = objCDR
  222.     'Check for media
  223.      If mobjCDPro.GetMediaType() = mtNotLoaded Then
  224.         MsgBox "No Media Loaded...Cannot Get Disc Info!", vbOKOnly + vbInformation, App.Title
  225.         Unload Me
  226.         Exit Sub
  227.      End If
  228.     'Show Form
  229.     Me.Show , frmParent
  230.     'Get Disc Information
  231.     SetStatus
  232. End Sub
  233. Private Sub SetStatus()
  234.     Dim lngBlocks As Long
  235.     'Default these to not enabled
  236.     cmdCloseDisc.Enabled = False
  237.     cmdCloseSession.Enabled = False
  238.     'Reset this flag
  239.     mblnClosing = False
  240.     'Set number of Sessions
  241.     lblValueSessions.Caption = mobjCDPro.GetSessionCount()
  242.         
  243.     'Free Space blocks
  244.     lngBlocks = mobjCDPro.GetDiscFreeSpaceBlocks()
  245.     lblValueFreeSpaceBlocks.Caption = CStr(lngBlocks) & " Blocks Free"
  246.     'Set Media Type label
  247.     Select Case mobjCDPro.GetMediaType()
  248.         Case mtCD   'CDR
  249.             lblValueMediaType.Caption = "CD-R"
  250.         Case mtCDRW   'CDR/W
  251.             lblValueMediaType.Caption = "CD-RW"
  252.         Case mtDVDMR   'DVD-R
  253.             lblValueMediaType.Caption = "DVD-R"
  254.         Case mtDVDMRW   'DVD-R/W
  255.             lblValueMediaType.Caption = "DVD-RW"
  256.         Case mtDVDPR   'DVD+R
  257.             lblValueMediaType.Caption = "DVD+R"
  258.         Case mtDVDPRW   'DVD+RW
  259.             lblValueMediaType.Caption = "DVD+RW"
  260.         Case mtDVDRam   'DVD-RAM
  261.             lblValueMediaType.Caption = "DVD-RAM"
  262.         Case mtDVDRom   'DVD-ROM
  263.             lblValueMediaType.Caption = "DVD-ROM"
  264.         Case mtNotLoaded 'Should never see this
  265.             lblValueMediaType.Caption = "Not Loaded"
  266.     End Select
  267.     'Set Disc Status label
  268.     Select Case mobjCDPro.GetDiscStatus()
  269.         Case dsComplete
  270.             lblValueDiscStatus.Caption = "Disc is Closed"
  271.         Case dsEmpty
  272.             lblValueDiscStatus.Caption = "Empty Disc"
  273.         Case dsIncomplete
  274.             lblValueDiscStatus.Caption = "Disc Open"
  275.         Case dsUnknown
  276.             lblValueDiscStatus.Caption = "Unknown"
  277.     End Select
  278.         
  279.     'Set Disc Type label this only applies to CD type media
  280.     Select Case mobjCDPro.GetDiscType()
  281.         Case dtCddaCDRom 'Audio or Mode1 CDRom
  282.             lblValueDiscType.Caption = "CD-DA/CD-ROM"
  283.         Case dtCDI
  284.             lblValueDiscType.Caption = "CDI"
  285.         Case dtCDRomXA
  286.             lblValueDiscType.Caption = "CD-ROM XA"
  287.         Case dtUnknown
  288.             lblValueDiscType.Caption = "Unknown"
  289.     End Select
  290.     'Set Last Session Status
  291.     Select Case mobjCDPro.GetLastSessionStatus()
  292.         Case ssEmpty
  293.             lblValueLastSessionStatus.Caption = "Empty Session"
  294.         Case ssIncomplete
  295.             lblValueLastSessionStatus.Caption = "Incomplete Session"
  296.             'Let User Close disc/session
  297.             cmdCloseSession.Enabled = True
  298.             cmdCloseDisc.Enabled = True
  299.         Case ssComplete
  300.             lblValueLastSessionStatus.Caption = "Closed Session"
  301.         Case ssReserved
  302.             lblValueLastSessionStatus.Caption = "Unknown"
  303.     End Select
  304. End Sub
  305. Private Sub mobjCDPro_ClosingDisc()
  306.     lblStatus.Caption = "...Closing Disc..."
  307. End Sub
  308. Private Sub mobjCDPro_ClosingSession()
  309.     lblStatus.Caption = "...Closing Session..."
  310. End Sub
  311. Private Sub mobjCDPro_WriteComplete()
  312.     'Close is complete
  313.     lblStatus.Caption = "Closing Successful!!"
  314.     SetStatus
  315.     MsgBox "Session/Disc Closed Successful!", vbInformation + vbOKOnly, App.Title
  316.     mblnClosing = False
  317.     cmdOK.Enabled = True
  318. End Sub
  319. Private Sub mobjCDPro_WriteError(ByVal WriteError As CDRPROXLibCtl.eWriteErrorType, ByVal DriveError As CDRPROXLibCtl.eCDError, ByVal sErrorInfo As String, ByVal sSenseInfo As String)
  320.     Dim strError As String
  321.     'Get the error type and
  322.     strError = "Writing Error: (" & CStr(WriteError) & ")   " & sErrorInfo & vbCrLf
  323.     'If it is a drive error, add the drive error information
  324.     'to the displayed message
  325.     If WriteError = errDriveError Then
  326.         strError = strError & GetDriveErrorMessage(DriveError) & vbCrLf & " Error Sense Data: " & sSenseInfo
  327.     End If
  328.     'Display Msg to user
  329.     MsgBox strError, vbCritical + vbOKOnly
  330.     mblnClosing = False
  331.     Unload Me
  332. End Sub
  333.